Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools/gcc-frr-format: fix ICE in gcc-10 #7443

Merged
merged 1 commit into from
Nov 4, 2020

Conversation

eqvinox
Copy link
Contributor

@eqvinox eqvinox commented Nov 3, 2020

gcc-10 has a more strict internal assert for type checks so the plugin
currently causes an Internal Compiler Error. Fix.

The plugin works with gcc-9 and gcc-10 after this fix. The single line patch to gcc is still needed, cf. docs.

gcc-10 has a more strict internal assert for type checks so the plugin
currently causes an Internal Compiler Error.  Fix.

Signed-off-by: David Lamparter <[email protected]>
Copy link

@polychaeta polychaeta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution to FRR!

Click for style suggestions

To apply these suggestions:

curl -s https://gist.githubusercontent.com/polychaeta/cd50d31d43bf40af8b42ce32d75080b4/raw/521467ddf12d20175fd7c7e3230984fae124772f/cr_7443_1604361969.diff | git apply

diff --git a/tools/gcc-plugins/frr-format.c b/tools/gcc-plugins/frr-format.c
index 6d91d2cdc..881d81797 100644
--- a/tools/gcc-plugins/frr-format.c
+++ b/tools/gcc-plugins/frr-format.c
@@ -2730,13 +2730,12 @@ tree type_normalize (tree type, tree *cousin, tree target = NULL)
 }
 
 /* gcc-10 asserts when you give a TYPE_DECL instead of the actual TYPE */
-static tree
-decl_deref(tree typ)
+static tree decl_deref(tree typ)
 {
-  while (TREE_CODE (typ) == TYPE_DECL)
-    typ = DECL_ORIGINAL_TYPE (typ);
+	while (TREE_CODE(typ) == TYPE_DECL)
+		typ = DECL_ORIGINAL_TYPE(typ);
 
-  return typ;
+	return typ;
 }
 
 static void
@@ -2885,7 +2884,8 @@ check_format_types (const substring_loc &fmt_loc,
 			  || cur_type == signed_char_type_node
 			  || cur_type == unsigned_char_type_node);
 
-      int compat = lang_hooks.types_compatible_p (decl_deref (wanted_type), decl_deref (cur_type));
+      int compat = lang_hooks.types_compatible_p(decl_deref(wanted_type),
+						 decl_deref(cur_type));
       /* Check the type of the "real" argument, if there's a type we want.  */
       if ((TREE_CODE (wanted_type) != INTEGER_TYPE || types->pointer_count)
 	  && compat)
@@ -3192,8 +3192,8 @@ matching_type_p (tree spec_type, tree arg_type)
   gcc_assert (spec_type);
   gcc_assert (arg_type);
 
-  spec_type = decl_deref (spec_type);
-  arg_type = decl_deref (arg_type);
+  spec_type = decl_deref(spec_type);
+  arg_type = decl_deref(arg_type);
 
   /* If any of the types requires structural equality, we can't compare
      their canonical types.  */

If you are a new contributor to FRR, please see our contributing guidelines.

After making changes, you do not need to create a new PR. You should perform an amend or interactive rebase followed by a force push.

@eqvinox
Copy link
Contributor Author

eqvinox commented Nov 3, 2020

polychaeta style comments are irrelevant, the gcc plugin follows GCC coding style.

@LabN-CI
Copy link
Collaborator

LabN-CI commented Nov 3, 2020

💚 Basic BGPD CI results: SUCCESS, 0 tests failed

Results table
_ _
Result SUCCESS git merge/7443 cd67bcf
Date 11/02/2020
Start 19:10:43
Finish 19:37:09
Run-Time 26:26
Total 1815
Pass 1815
Fail 0
Valgrind-Errors 0
Valgrind-Loss 0
Details vncregress-2020-11-02-19:10:43.txt
Log autoscript-2020-11-02-19:11:43.log.bz2
Memory 468 497 428

For details, please contact louberger

@NetDEF-CI
Copy link
Collaborator

Continuous Integration Result: SUCCESSFUL

Congratulations, this patch passed basic tests

Tested-by: NetDEF / OpenSourceRouting.org CI System

CI System Testrun URL: https://ci1.netdef.org/browse/FRR-FRRPULLREQ-15137/

This is a comment from an automated CI system.
For questions and feedback in regards to this CI system, please feel free to email
Martin Winter - mwinter (at) opensourcerouting.org.

Warnings Generated during build:

Checkout code: Successful with additional warnings
Report for frr-format.c | 24 issues
===============================================
< WARNING: please, no spaces at the start of a line
< #2736: FILE: /tmp/f1-16514/frr-format.c:2736:
< WARNING: suspect code indent for conditional statements (2, 4)
< #2736: FILE: /tmp/f1-16514/frr-format.c:2736:
< WARNING: please, no spaces at the start of a line
< #2737: FILE: /tmp/f1-16514/frr-format.c:2737:
< WARNING: please, no spaces at the start of a line
< #2739: FILE: /tmp/f1-16514/frr-format.c:2739:
< WARNING: please, no spaces at the start of a line
< #2766: FILE: /tmp/f1-16514/frr-format.c:2766:
< WARNING: line over 80 characters
< #2888: FILE: /tmp/f1-16514/frr-format.c:2888:
< WARNING: space prohibited between function name and open parenthesis '('
< #2888: FILE: /tmp/f1-16514/frr-format.c:2888:
< WARNING: space prohibited between function name and open parenthesis '('
< #2888: FILE: /tmp/f1-16514/frr-format.c:2888:
< WARNING: please, no spaces at the start of a line
< #3195: FILE: /tmp/f1-16514/frr-format.c:3195:
< WARNING: space prohibited between function name and open parenthesis '('
< #3195: FILE: /tmp/f1-16514/frr-format.c:3195:
< WARNING: please, no spaces at the start of a line
< #3196: FILE: /tmp/f1-16514/frr-format.c:3196:
< WARNING: space prohibited between function name and open parenthesis '('
< #3196: FILE: /tmp/f1-16514/frr-format.c:3196:

Warnings Generated during build:

Debian 10 amd64 build: Successful with additional warnings

Debian Package lintian failed for Debian 10 amd64 build:
(see full package build log at https://ci1.netdef.org/browse/FRR-FRRPULLREQ-15137/artifact/DEB10BUILD/ErrorLog/log_lintian.txt)

W: frr source: pkg-js-tools-test-is-missing
W: frr source: newer-standards-version 4.5.0.3 (current is 4.3.0)
W: frr source: pkg-js-tools-test-is-missing
W: frr source: newer-standards-version 4.5.0.3 (current is 4.3.0)
W: frr-doc: changelog-file-missing-explicit-entry 6.0-2 -> 7.6-dev-20201102-01-gcd67bcf99-0 (missing) -> 7.6-dev-20201102-01-gcd67bcf99-0~deb10u1
W: frr-pythontools: changelog-file-missing-explicit-entry 6.0-2 -> 7.6-dev-20201102-01-gcd67bcf99-0 (missing) -> 7.6-dev-20201102-01-gcd67bcf99-0~deb10u1
W: frr: changelog-file-missing-explicit-entry 6.0-2 -> 7.6-dev-20201102-01-gcd67bcf99-0 (missing) -> 7.6-dev-20201102-01-gcd67bcf99-0~deb10u1
W: frr-snmp: changelog-file-missing-explicit-entry 6.0-2 -> 7.6-dev-20201102-01-gcd67bcf99-0 (missing) -> 7.6-dev-20201102-01-gcd67bcf99-0~deb10u1
W: frr-rpki-rtrlib: changelog-file-missing-explicit-entry 6.0-2 -> 7.6-dev-20201102-01-gcd67bcf99-0 (missing) -> 7.6-dev-20201102-01-gcd67bcf99-0~deb10u1

@mjstapp
Copy link
Contributor

mjstapp commented Nov 3, 2020

I'm not getting an ICE with gcc-10, at least not with normal 10.2.0. Do I actually have to build from source in order to even see the problem?

@eqvinox
Copy link
Contributor Author

eqvinox commented Nov 3, 2020

I'm not getting an ICE with gcc-10, at least not with normal 10.2.0. Do I actually have to build from source in order to even see the problem?

The plugin is not used by default, cf. docs in https://github.com/FRRouting/frr/blob/master/tools/gcc-plugins/README.md

@mjstapp
Copy link
Contributor

mjstapp commented Nov 3, 2020

I'm not getting an ICE with gcc-10, at least not with normal 10.2.0. Do I actually have to build from source in order to even see the problem?

The plugin is not used by default, cf. docs in https://github.com/FRRouting/frr/blob/master/tools/gcc-plugins/README.md

umm, I meant "if I use the plugin and compile the test source file, I don't get an internal error" with gcc-9 or -10.

@eqvinox
Copy link
Contributor Author

eqvinox commented Nov 3, 2020

umm, I meant "if I use the plugin and compile the test source file, I don't get an internal error" with gcc-9 or -10.

Oh, sorry, I misunderstood. The ICE is triggered by the fine distinction between type declarations and types; I didn't investigate when exactly you get a type decl (might involve casts, or not-previously-declared types) but it happens in several locations when you build the FRR source. The test program doesn't exhibit the ICE since it's all types there. Sadly, figuring out a test case for this would probably take an order of magnitude longer than the actual fix here...

[Add.: that it ICEs in FRR build is also what made me jump to "you need to enable the plugin"]

@donaldsharp donaldsharp merged commit 9535a96 into FRRouting:master Nov 4, 2020
@eqvinox eqvinox deleted the gcc-10-plugin-ice branch April 18, 2021 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants